let myclock = document.getElementById("myclock");
let startBtn = document.getElementById("startBtn");
let stopBtn = document.getElementById("stopBtn");
callback();
let mytimer = setInterval(callback, 1000);
function callback() {
    var mydate = new Date();
    myclock.innerHTML = mydate.getHours() +
        ":" + mydate.getMinutes() +
        ":" + mydate.getSeconds();
}
//启动按钮事件
startBtn.onclick = function () {
    if (mytimer == null) {
        mytimer = setInterval(callback, 1000);
    }
};
//停止按钮事件
stopBtn.onclick = function () {
    clearInterval(mytimer);
    mytimer = null;
};